package com.osfw.dbadminer.service.connect.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.osfw.dbadminer.entity.connect.DbaConnectDatabase;
import com.osfw.dbadminer.mapper.connect.DbaConnectDatabaseMapper;
import com.osfw.dbadminer.service.connect.IDbaConnectDatabaseService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 连接配置管理--自定义数据库列表 服务层处理
 */
@Service
public class DbaConnectDatabaseServiceImpl extends ServiceImpl<DbaConnectDatabaseMapper, DbaConnectDatabase> implements IDbaConnectDatabaseService {

    @Override
    public List<String> getFilterDbByConnectId(Long connectId) {
        List<DbaConnectDatabase> list = this.lambdaQuery()
                .select(DbaConnectDatabase::getDatabase)
                .eq(DbaConnectDatabase::getConnectId, connectId)
                .list();
        return list.stream().map(x -> x.getDatabase()).collect(Collectors.toList());
    }
}
